//go:generate go run github.com/vektah/dataloaden UserExtraInfoLoader int64 *gql/graph/model.UserExtraInfo

package model

import (
	"gql3/db"
	"time"
)

type UserExtraInfo struct {
	ID        int64 `gorm:"primarykey" json:"id"`
	CreatedAt time.Time
	UpdatedAt time.Time
	Address   *string  `json:"address"`
	Phone     *string  `json:"phone"`
	Sex       *SexEnum `json:"sex"`
}

func (u *UserExtraInfo) NewLoader() *UserExtraInfoLoader {
	return &UserExtraInfoLoader{
		wait:     2 * time.Millisecond,
		maxBatch: 100,
		fetch: func(keys []int64) ([]*UserExtraInfo, []error) {
			res := make([]*UserExtraInfo, len(keys))
			db.DB.Model(&UserExtraInfo{}).Find(&res, keys)
			return res, nil

		},
	}
}
